home *** CD-ROM | disk | FTP | other *** search
- /*
- * fgetss() is like fgets() except that the terminating newline
- * is removed.
- */
- #include <stdio.h>
-
- char *fgetss(s, n, iop)
- char *s;
- register FILE *iop;
- {
- register c;
- register char *cs;
-
- cs = s;
- while ((c = getc(iop)) >= 0 && --n > 0)
- {
- *cs++ = c;
- if (c == '\n')
- break;
- }
- if (c < 0 && cs == s)
- return(NULL);
- cs[-1] = '\0'; /* Overwrite newline as null */
- return(s);
- }